import os
import subprocess
url = "https://mirrors.163.com/fedora/releases/36/Everything/source/tree/Packages/"
heads = [str(x) for x in range(0, 10)] + [chr(y) for y in range(97, 123)]


def check_blacklist(package_name):
    file = open("", 'r')
    lineslist = file.readlines()
    for line in lineslist:
        if(package_name).find(line)>=0:
            return True
    return False


for head in heads:
    html = '{}.html'.format(head)
    os.system('curl {}/{}/'.format(url, head) + ' > ' + html)
    for line in open(html, 'r'):
        start = line.find('href=')
        end = line.find('src.rpm')
        if start > 0 and end > 0:
            package_name = line[start + 6: end]

            if check_blacklist(package_name):
                continue
                os.system('echo {} >> rpm_build_fail.txt'.format(package_name))
